home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Cream of the Crop 26
/
Cream of the Crop 26.iso
/
program
/
tcqbsnip.zip
/
REPSTR.BAS
< prev
next >
Wrap
BASIC Source File
|
1997-06-20
|
898b
|
33 lines
' REPSTR.BAS
' by Tika Carr
' December 7, 1996
'
' Donated to the Public Domain
' No warranties or guarantees are expressed or implied.
'
' Purpose: Search for specific text in a string and replace it with something
' else. This routine is case sensitive.
DECLARE FUNCTION RepStr$ (A$, S$, R$)
CLS
Original$ = "Hello, I'm Name. How are you?" 'Original String
Target$ = "Name" 'What we are going to replace
Replace$ = "Somebody" 'What we will replace it with
PRINT "Original: "; Original$
PRINT "Search String: "; Target$
PRINT "Replace with: "; Replace$
'Call function to do work:
PRINT "Modified: "; RepStr$(Original$, Target$, Replace$)
FUNCTION RepStr$ (A$, S$, R$)
T = INSTR(A$, S$)
IF T > 0 THEN A$ = LEFT$(A$, T - 1) + R$ + RIGHT$(A$, LEN(A$) - T - LEN(S$) + 1)
RepStr$ = A$
END FUNCTION